/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
// 用于业务流程异常和手动抛出异常
export class BusinessError extends Error {
  name = 'BusinessError'

  constructor({ requestOptions, response, message, send = true }) {
    super(message)
    Object.assign(this, {
      requestOptions,
      response,
      send,
    })
  }
}

// 用于网络请求错误
export class NetworkError extends Error {
  name = 'NetworkError'

  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
  constructor({ requestOptions, response, message = '网络异常,请稍后重试' }) {
    super(message)
    Object.assign(this, {
      requestOptions,
      response,
    })
  }
}

// 抛出异常，但不给用户提示
export class SystemError extends Error {
  name = 'SystemError'
}

// 超时错误
export class TimeOutError extends Error {
  name = 'TimeOutError'
}
